﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Form.Master" AutoEventWireup="true" CodeBehind="Form.aspx.cs" Inherits="BBPA.Admin.Sys.Orders.Buying.Form" %>

<%@ MasterType VirtualPath="~/Form.Master" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
    <script>
        var keyRanIndex = 0;
        function Event_Amount_change() {
            $('[id$=tb_ActualAmount],[id$=tb_ActualGiftNumber]')
                .bind('input propertychange', function () {
                    $(this).parents("tr").find("[id$=bt_HasBuy]").attr("disabled", "disabled");
                    if ($(this).val() == "") return;
                    var newIndex = rand(600);;
                    keyRanIndex = newIndex;
                    setTimeout(function () { if (keyRanIndex == newIndex) $('[id$=bt_submit]').click(); }, 1000);
                    //if (!throttleTimeout_index) {
                    //    throttleTimeout_index = setTimeout(function () { $('[id$=bt_submit]').click(); throttleTimeout_index = null; }, 500);
                    //}
                })
                .focusout(function () {
                    if ($(this).val() == "") $(this).val($(this).attr("data-val"));
                   // else { keyRanIndex = rand(600); $('[id$=bt_submit]').click(); }
                });
            $(".formTable [href-info]").fastClick(function () {
                var me = $(this);
                parent.open_popover(me, getAbsoluteUrl(me.attr("href-info")), "" + me.parents("tr").attr("data-row-title"), true);
            });
            $(".td_BuyPrice .fa-edit").fastClick(function () {
                var thisTd = $(this).parents(".td_BuyPrice");
                thisTd.find(".info").hide();
                thisTd.find(".edit").show();
            });
            $(".td_BuyPrice .btn-link").fastClick(function () {
                var thisTd = $(this).parents(".td_BuyPrice");
                thisTd.find(".edit").hide();
                thisTd.find(".info").show();
                return false;
            });
            $(".td_BuyPrice .btn-primary").fastClick(function () {
                var buyPrice_val=$(this).parents(".edit").find("[id$=tb_BuyPrice]").val();
                if (buyPrice_val == "" || buyPrice_val == "0" || buyPrice_val==0) alert("请输入要修改的价格"); {
                    $('[id$=bt_submit]').click();
                    return false;
                }
            });
        }
    </script>
    <style>
        .td_BuyPrice .btn { position: absolute; margin-top: 32px; }
        .tb_BuyPrice .fa { cursor: pointer; }
        .td_BuyPrice .btn-primary { }
        .td_BuyPrice .btn-link { margin-left: 40px; }
        .SellWay { position: absolute; margin-top: 20px; }
    </style>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="cph_main" runat="server">

    <asp:Repeater ID="rp_Goods" runat="server" OnItemDataBound="rp_Goods_ItemDataBound" OnItemCommand="rp_Goods_ItemCommand">
        <HeaderTemplate>
            <table class="formTable haveBorder">
                <thead>
                    <tr>
                        <th rowspan="2">商品</th>
                        <th colspan="3" style="border-left: 1px dashed #e5e5e5">预计采购</th>
                        <th colspan="4" style="border-left: 1px dashed #e5e5e5">实际采购</th>
                        <th></th>
                    </tr>
                    <tr>
                        <th style="text-align: center; border-left: 1px dashed #e5e5e5">价格</th>
                        <th style="text-align: center">数量</th>
                        <th style="text-align: right">小计</th>

                        <th style="text-align: center; border-left: 1px dashed #e5e5e5;">价格</th>
                        <th style="text-align: center">数量</th>
                        <th style="text-align: center">赠送</th>
                        <th style="text-align: right">小计</th>
                        <th></th>
                    </tr>
                </thead>
        </HeaderTemplate>
        <ItemTemplate>
            <tr id="tr_SupplierName" runat="server"><td colspan="9" style="padding-bottom:0;padding-top:24px;border-left:1px solid #fff;border-right:1px solid #fff;">
                供货商：<b><%#Eval("SupplierShortName") %></b> 
                <i class="fa fa-mobile <%#DataTypePlus.requestString(Eval("Mobile"))!=""?"":"hide" %>" style="margin-left:10px;"> <%# Eval("Mobile") %></i>
                 <i class="fa fa-phone <%#DataTypePlus.requestString(Eval("Tel"))!=""?"":"hide" %>" style="margin-left:10px;"> <%#Eval("Tel") %></i>
                 <%#(bool)Eval("IsLatePay")?" 后付款":"" %><%#(bool)Eval("IsDelivery")?" 送货":"" %></td></tr>
            <tr data-key-id="<%#Eval("GoodsID") %>" data-row-title="<%#Eval("Name") %>" style="background-color:#fdfdfd;">
                <td>
                    <asp:TextBox ID="tb_id" runat="server" CssClass="hide" Text='<%# Eval("id") %>'></asp:TextBox>
                    <a href="###" href-info="../../goods/info.aspx?id=<%#Eval("GoodsID") %>&HideOrderForm=1" style="display: block; overflow: hidden; min-width: 200px;">
                        <img src="<%#Eval("PicURL") %>" style="width: 80px; margin-right: 10px;" class=" pull-left" />
                        <%#Eval("Number") %> <%#Eval("BrandName") %> <%#Eval("Name") %> <%#Eval("Code") %>
                    </a>
                    <div style="line-height: initial;" class="alert <%#DataTypePlus.requestString( Eval("Description"))==""?"hide":"" %>"><%#Eval("Description") %></div>
                </td>
               

                <td style="text-align: center; border-left: 1px dashed #e5e5e5"><%#StringPlus.showCoin( Eval("ExpectBuyPrice")) %></td>
                <td style="text-align: center">
                    <div class="label label-info SellWay <%#(int)Eval("ExpectBuyGiftNumber")==0?"hide":"" %>">赠<%#Eval("ExpectBuyGiftNumber") %></div>
                    <%#Eval("ExpectAmount") %>
                </td>
                <td style="text-align: right" class=" text-error">
                    <div class="label label-info SellWay <%#(int)Eval("ExpectBuyDiscount")==100?"hide":"" %>"><%#DataTypePlus.requestDecimal( Eval("ExpectBuyDiscount"))/10 %>折</div>
                    <%# StringPlus.showCoin( Eval("ExpectBuyPriceSum") )%>
                </td>

                <td class="td_BuyPrice nowrap" style="text-align: center; border-left: 1px dashed #e5e5e5">
                    <div style="width: 78px"></div>
                    <span class="info  <%#(bool)Eval("HasBuy")?"hide":"" %>"><%#StringPlus.showCoin( Eval("BuyPrice")) %> <i class="fa fa-edit"></i></span>
                    <span class="edit hide">
                        <button class="btn btn-mini btn-primary">修改</button>
                        <button class="btn btn-mini btn-link">取消</button>
                        <asp:TextBox ID="tb_BuyPrice" runat="server" CssClass="input-mini" placeholder="新的价格" Text='<%#StringPlus.showCoin( Eval("BuyPrice")) %>'></asp:TextBox>
                    </span>
                    <span class="<%#(bool)Eval("HasBuy")?"":"hide" %>"><%#StringPlus.showCoin( Eval("ActualBuyPrice")) %></span>
                </td>
                <td style="text-align: center">
                    <span class="<%#(bool)Eval("HasBuy")?"":"hide" %>"><%#Eval("ActualAmount") %></span>
                    <asp:TextBox ID="tb_ActualAmount" runat="server" Style="width: 24px" Text='<%#Eval("ActualAmount") %>'  data-val='<%#Eval("ActualAmount") %>' Visible='<%#!(bool)Eval("HasBuy") %>'></asp:TextBox></td>
                <td style="text-align: center">
                    <span class="<%#(bool)Eval("HasBuy")?"":"hide" %>"><%#Eval("ActualGiftNumber") %></span>
                    <asp:TextBox ID="tb_ActualGiftNumber" runat="server" Style="width: 24px" Text='<%#Eval("ActualGiftNumber") %>' data-val='<%#Eval("ActualGiftNumber") %>'  Visible='<%#!(bool)Eval("HasBuy") %>'></asp:TextBox></td>
                <td itemsum="1" class="text-error text-right">
                    <div class="label label-info SellWay <%#((bool)Eval("IsLatePay"))||(!(bool)Eval("HasBuy")&& BBPA.BLL.Goods.GetBuyDiscount(Eval("GoodsID"),Eval("ActualAmount"))==100)||((bool)Eval("HasBuy")&&(int)Eval("ActualBuyDiscount")==100)?"hide":"" %>">
                        <%#DataTypePlus.requestDecimal( BBPA.BLL.Goods.GetBuyDiscount(Eval("GoodsID"),Eval("ActualAmount")))/10 %>折</div>
                   
                    <asp:Label ID="lb_Goods_ActualBuyPriceSum" runat="server"></asp:Label>
                </td>
                <td>
                    <asp:Button ID="bt_HasBuy" runat="server" Text="完成" CssClass="btn btn-primary" CommandName="HasBuy" CommandArgument='<%#Eval("id") %>'  Visible='<%#!(bool)Eval("HasBuy") %>'  OnClientClick="this.disabled=true;" UseSubmitBehavior="False"/>
                    
                    <asp:Button ID="bt_HasBuy0" runat="server" Text="放弃" CssClass="btn btn-inverse  btn-mini" CommandName="HasBuy0" CommandArgument='<%#Eval("id") %>'  Visible='<%#!(bool)Eval("HasBuy") %>'  OnClientClick="this.disabled=true;" UseSubmitBehavior="False" style="position:absolute;margin:5px 0 0 10px;"/>

                </td>
            </tr>
            <tr id="tr_xiaoji" runat="server">
                <td colspan="4" style="padding-top:0;padding-bottom:24px;border-left:1px solid #fff;border-right:1px solid #fff;border-bottom:1px solid #fff; text-align:right;">
                本供货商 预计合计：<asp:Label ID="lb_Supplier_ExpectBuyPriceSum" runat="server" CssClass="text-error"></asp:Label></td>
                <td colspan="5" style="padding-top:0;padding-bottom:24px;border-left:1px solid #fff;border-right:1px solid #fff;border-bottom:1px solid #fff; text-align:right;">
                本供货商 实际合计：<asp:Label ID="lb_Supplier_ActualBuyPriceSum" runat="server" CssClass="text-error"></asp:Label>
            </td></tr>
        </ItemTemplate>
        <FooterTemplate>
            <tr class="hide">
                <td></td>
                <td colspan="3" style="border-left: 1px dashed #e5e5e5">
                    <h4 style="text-align: right;" class="text-error nowrap">合计：<asp:Label ID="lb_ExpectPay" runat="server" Text=""></asp:Label></h4>
                </td>

                <td colspan="4" style="border-left: 1px dashed #e5e5e5">
                    <h4 style="text-align: right;" class="text-error nowrap">合计：<%=StringPlus.showMoney( ActualBuyPriceSum) %></h4>
                </td>
                <td></td>
            </tr>
            </table>
                
        </FooterTemplate>
    </asp:Repeater>


</asp:Content>
